// Name：P2_8.c
// Purpose：计算还贷金额
// Author：wjy
// From：《C语言程序设计：现代方法》（第二版）第二章第8题
// Date：2021.12.29

#include <stdlib.h> 
#include <stdio.h>

int main(void)
{
    float amount;
    float rate;
    float payment;
    printf ("Enter amount of loan: ");
    scanf ("%f", &amount);
    printf ("Enter interest rate: ");
    scanf ("%f", &rate);
    printf ("Enter monthly payment: ");
    scanf ("%f", &payment);
    rate = rate / 1200.0f;
    printf ("Balance remaining after first payment: $%.2f\n", amount * (1.0f + rate) - payment);
    amount = amount * (1.0f + rate) - payment;
    printf ("Balance remaining after second payment: $%.2f\n", amount * (1.0f + rate) - payment);
    amount = amount * (1.0f + rate) - payment;
    printf ("Balance remaining after third payment: $%.2f\n", amount * (1.0f + rate) - payment);
    system ("pause");
    return 0;
}